package com.xin.di.uav.applet.controller;

import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Data
@Configuration
public class WxPayConfig {
    @Value("${wxpay.mch-id:1727006153}")
    private String merchantId;

    @Value("${wxpay.mch-serial-no:1a0d73e8bd8f023d56afee6eb6d028f7a9068b97}")
    private String merchantSerialNumber;

    @Value("${wxpay.api-v3-key:5Z9A4Gr12Y549Xd73E2Tr45T3EBV678p}")
    private String apiV3Key;

    @Value("${wx.key-path:D:\\1727006153_20250909_cert\\apiclient_key.pem}")
    private String privateKeyPath;

    public RSAAutoCertificateConfig getConfig() throws IOException {
        return new RSAAutoCertificateConfig.Builder()
                .merchantId(merchantId)
                .privateKeyFromPath(privateKeyPath)
                .merchantSerialNumber(merchantSerialNumber)
                .apiV3Key(apiV3Key)
                .build();
    }
}
